home *** CD-ROM | disk | FTP | other *** search
/ isnet Internet / Isnet Internet CD.iso / prog / hiz / 09 / 09.exe / adynware.exe / perl / lib / adynware / spit.pl < prev    next >
Encoding:
Perl Script  |  2000-05-01  |  845 b   |  39 lines

  1. require 5.004;
  2. use strict;
  3. use IO::Socket;
  4. use IO::File;
  5.  
  6. my $spit__host = "127.0.0.1";
  7. my $spit__port = 38200;
  8. my $spit__data = "stop";
  9.  
  10. sub Init
  11. {
  12.         return unless @ARGV;
  13.         $_ = shift @ARGV;
  14.         if (/([\w\.]+):(\d+)/)
  15.         {
  16.                 $spit__host = $1;
  17.                 $spit__port = $2;
  18.                 $_ = shift @ARGV;
  19.         }
  20.         $spit__data = $_ if $_;
  21. }
  22.  
  23. sub Main
  24. {
  25.         my $server = IO::Socket::INET->new(PeerAddr => $spit__host, PeerPort => $spit__port, Proto => 'tcp');
  26.         if (!$server)
  27.         {
  28.                 print "could not connect to $spit__host:$spit__port\n";
  29.                 return;
  30.         }
  31.         print "sending '$spit__data' to $spit__host:$spit__port\n";
  32.         print $server $spit__data;
  33.         close $server;
  34. }
  35.  
  36. Init();
  37. Main();
  38.  
  39. # test with: perl -w $HOME/work/bin/perl/spit.pl